package com.fangsiqi.maven.users.dao;

import com.fangsiqi.maven.users.entity.User;

public class UserDao {
	private static final int MAX_SIZE=1000;
	private static final User[] USERS=new User[MAX_SIZE];
	private static  int index=0;

	public boolean save(User user) {
		USERS[index]=user;
		index++;
		user.setId(index);
		return true;
	}

	public User queryByUsername(String username) {
		for (int i = 0; i < USERS.length; i++) {
			User user = USERS[i];
			if(user!=null && user.getUsername().equals(username)) {
				return user;
			}
		}
		return null;
	}
}
